﻿using System;
using System.Windows;
using CI.Models;
using CI.ViewModels.Interfaces;
using GongSolutions.Wpf.DragDrop;

namespace CI.ViewModels.Diagramming
{
    public class CharacterVertexViewModel : IVertexViewModel, IDropTarget
    {
        public ICharacter Character { get; private set; }
        public IDiagramViewModel ParentViewModel { get; private set; }

        public CharacterVertexViewModel(ICharacter character, IDiagramViewModel parentModel)
        {
            Character = character;
            ParentViewModel = parentModel;
        }

        public void DragOver(IDropInfo dropInfo)
        {
            if (dropInfo.Data is Activity)
            {
                dropInfo.Effects = DragDropEffects.Copy;
            }
            else dropInfo.IsNotHandled = true;
        }

        public void Drop(IDropInfo dropInfo)
        {
            if (dropInfo.Data is Activity)
            {
                ParentViewModel.Model.AddNodeWithLink(dropInfo.Data, this.Character);
            }
        }
    }
}